package com.taoz.rpc.core.serializer;

import com.taoz.rpc.core.config.ApplicationConfig;
import com.taoz.rpc.core.spi.SpiLoader;

public class SerializerFactory {
    static {
        SpiLoader.load(Serializer.class);
    }

    public static Serializer getSerializer(String className) throws InstantiationException, IllegalAccessException {
        return (Serializer) SpiLoader.getInstance(className);
    }

    public static Serializer getSerializer() throws InstantiationException, IllegalAccessException {
        String className = ApplicationConfig.getConfig().getSerializer();
        return (Serializer) SpiLoader.getInstance(className);
    }
}
